package com.shujia.mllib

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.mllib.classification.LogisticRegressionModel
import org.apache.spark.mllib.linalg
import org.apache.spark.mllib.linalg.Vectors

object Demo3ModelRun {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf().setMaster("local").setAppName("test")
    val sc: SparkContext = new SparkContext(conf)


    //1、加载模型
    val model: LogisticRegressionModel = LogisticRegressionModel.load(sc, "spark/data/model")

    /**
      * 0 1:4.7 2:3.3 3:2.5 4:97.6 5:73.8 6:62.1 7:93
      *
      */

    val vector: linalg.Vector = Vectors.dense(Array(4.7, 3.3, 2.5, 97.6, 73.8, 62.1, 93))


    //预测新的数据
    val p: Double = model.predict(vector)

    println(p)


  }
}
